package com.xiaowei.gym.gymjsp.ware.service.impl;

import com.xiaowei.gym.gymjsp.ware.dao.EquipmentDao;
import com.xiaowei.gym.gymjsp.ware.dao.impl.EquipmentDaoImpl;
import com.xiaowei.gym.gymjsp.ware.entity.EquipmentEntity;
import com.xiaowei.gym.gymjsp.ware.service.EquipmentService;

import java.util.List;

public class EquipmentServiceImpl implements EquipmentService {

    private EquipmentDao equipmentDao;

    public EquipmentServiceImpl() {
        equipmentDao = new EquipmentDaoImpl();
    }

    @Override
    public int getCount() {
        return equipmentDao.getCount();
    }

    @Override
    public List<EquipmentEntity> getEquipmentList(String name, int currentPageNo, Integer pageSize) {
        return equipmentDao.getList(name,currentPageNo,pageSize);
    }

    @Override
    public EquipmentEntity getById(Integer valueOf) {
        return equipmentDao.getById(valueOf);
    }

    @Override
    public boolean modify(EquipmentEntity equipmentEntity) {
        int i = equipmentDao.updateEquipment(equipmentEntity);
        if (i > 0){
            return true;
        }
        return false;
    }

    @Override
    public int add(EquipmentEntity equipmentEntity) {
        return equipmentDao.createEquipment(equipmentEntity);
    }

    @Override
    public boolean delByIds(Integer[] delId) {
        int[] i = equipmentDao.deleteEquipmentByIds(delId);
        if (i != null){
            return true;
        }else {
            return false;
        }
    }
}
